<template>
    <div id="versionHistory">
      <el-button @click="back" type="primary" class="backBtn">返回</el-button>
       <el-table :data="versionHistory" stripe style="width:100%">
        <el-table-column prop="id"             label="序号"     width="80"></el-table-column>
        <el-table-column prop="channelText"    label="客户端"   width="80"></el-table-column>
        <el-table-column prop="version"        label="版本号"   width="80"></el-table-column>
        <el-table-column prop="phoneType"      label="操作系统"  width="120"></el-table-column>
        <el-table-column prop="isFocusUpdateText"     label="强制更新"  width="120"></el-table-column>
        <el-table-column prop="name"           label="标题"     width="200"></el-table-column>
        <el-table-column prop="description"    label="描述"     min-width="400"></el-table-column>
        <el-table-column prop="LastUpdated"    label="时间"     width="180"></el-table-column>
        <el-table-column prop="operator"       label="操作人"   width="90"></el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </div>
</template>
<script>
import { getHistoryList } from 'api/system/index.js'
export default {
  data () {
    return {
      versionHistory: [],
      total: 0,
      currentPage: 0,
      pageSize: 10,
      curPage: 0
    }
  },
  created () {
    this.$emit('setTitleMsg', ['系统管理', '版本管理', '查看历史版本']);
    this.getHistoryList()
  },
  methods: {
    async getHistoryList () {
      try {
        let params = {
          channel: this.$route.query.channel,
          phoneType: this.$route.query.phoneType,
          curPage: this.curPage,
          pageSize: this.pageSize,
          orderBy: 'id',
          xsc: 'desc'
        }
        let back = await getHistoryList(params);
        back = back.data;
        if (back.resultCode === '200') {
          this.versionHistory = [...back.result];
          this.total = back.size;
        } else {
          this.$alert(back.msg);
        }
      } catch (err) {
        this.$alert('请求出错', '提示');
      }
    },
    handleSizeChange (val) {
      this.pageSize = val;
      this.getHistoryList();
    },
    handleCurrentChange (val) {
      this.curPage = val - 1;
      this.getHistoryList();
    },
    back () {
      this.$router.push({name: 'versionManagement'})
    }
  }
}
</script>
<style scoped>
  .backBtn{
    margin-bottom:1rem;
  }
  .block{
    float: right;
    margin-top: 2rem;
  }
</style>

